# How the Multistate push button works at run time

When the operator first presses the button, it changes from State 0 to State 1 and sends the State 1 value to the data source. When the operator presses the button a second time, it changes from State 1 to State 2 and sends the State 2 value to the data source. Thus the state is incremented by one for each button press. When the button is in the last configured state and the operator presses it, it changes to State 0 and sends the State 0 value to the data source.

The Multistate push button’s behavior at run time also depends on how you set up the Next state based on option, auto repeat options, and controls.

## Change states

The application uses the Next state based on option (specified on the General tab of the Multistate Push Button dialog box) to determine how to change the button’s state.

- When the operator presses the button, if Next state based on is set to Value, and the control’s value does not match any of the states’ values, the button is set to State 0 and the application writes the State 0 value to the data source.

## Use auto repeat

Set up the Auto repeat rate and Auto repeat delay options on the Timing tab of the Multistate Push Button dialog box.

- When the operator presses the button, the auto repeat delay starts timing. The application continues timing until the operator releases the button or until the time reaches the Auto repeat delay time. If the Auto repeat delay time is reached, the button goes into auto repeat mode until the operator releases the button. Once in auto repeat mode, the application uses the Auto repeat rate option to determine the number of button presses per second to send to the data source.
- When in auto repeat mode, the application does not read the Value connection to determine the next value to write out, regardless of the Next state based on setting. The application uses the last value written out to determine the next value to write out.

## Use controls

- If you assign just the Value connection and not the Indicator connection, the button’s pressed state is shown as soon as the button is pressed. The feedback for this connection is local and immediate. It does not necessarily reflect the Value connection’s value in the data source.
- If you assign the same tag to the Value and Indicator controls, at run time the shown button state is based on the Indicator connection. If network traffic is heavy, the display response might be delayed.
- If the Indicator connection value is a floating point value, the application rounds the value to the nearest integer to determine the state to display.

## Start projects

When you open the display at run time, the application reads the Value connection and sets the button to this state, regardless of the Next state based on setting.

Open and close graphic displays

- When you open a display at run time, the application reads the Value connection value, but does not write the value to the data source.
- When you open a display at run time, the application reads the Indicator connection value and updates the display based on the value, unless the Value connection is unassigned.
- When you close a display at run time, if the button is in auto repeat mode, the button is released and the application writes the current value to the Value connection.

## See also

Causes of run-time errors for the Multistate push button

About the Multistate push button's error state

Set up controls for the Multistate push button

Configure the Maintained push button

Example: Use a Multistate push button